package com.lj.demo.springbootshirojwt.service.impl;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.lj.demo.springbootshirojwt.service.IResourceService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Title: 资源service实现类
 * Description:
 * Date: 2019年06月27日 8:58
 *
 * @author lvjie@hiynn.com
 * @version 1.0
 * Significant Modify：
 * Date                  Author                 Content
 * =================================================================
 * 2019年06月27日         lvjie@hiynn.com         创建文件,实现基本功能
 * =================================================================
 */
@Service
public class ResourceServiceImpl implements IResourceService {

    private static final Logger LOGGER = LoggerFactory.getLogger(ResourceServiceImpl.class);

    /**
     * 修改资源列表  需要能修改资源的权限
     */
    @Override
    @RequiresPermissions("RESOURCE_UPDATE")
    public void updateResource() {
        LOGGER.info("模拟修改对象,success");
    }

    /**
     * 获取资源列表  登录可访问
     * @return
     */
    @Override
    @RequiresAuthentication
    public List<Map<String, Object>> listResources() {
        LOGGER.info("模拟数据库查询");
        List<Map<String,Object>> resources = Lists.newArrayList();
        Map<String,Object> resource = Maps.newHashMapWithExpectedSize(2);
        resource.put("name","Java开发手册");
        resource.put("id","123456789");
        resources.add(resource);
        return resources;
    }
}
